<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
	<title>新增分组</title>
	<link rel="stylesheet" href="/layui/css/layui.css">
	<style type="text/css">
		body{
			background: #e9e9e9;
		}
		/*公共头部带搜索*/
		.public_container{
			margin: 20px;
			background: #fff;
		}
		.public_title_container{
			height: 54px;
			padding: 0 20px;
			font-size: 14px;
			display: flex;
			align-items: center;
			background: #f9f9f9;
			border-bottom: 1px solid #f0f0f0;
			justify-content: space-between;
		}
		.public_title_container a{
			fill: #999;
		}
		/*公共表单部分*/
		.public_form_container{
			padding: 20px 20px 40px 20px;
		}
		.public_form_content{
			padding: 24px 40px 24px 0;
			background: #fff;
			border: 1px solid #e9e9e9;
			margin-bottom: 8px;
		}
		.public_form_List{
			margin-bottom: 10px;
		}
		.public_form_List:last-child{
			margin-bottom: 0px;
		}
		.public_formTitle_container lable{
			font-size: 13px;
			font-weight: bold;
		}
	</style>
</head>
<body>
	<form class="layui-form" id="form1">
		

		<div class="public_container">
			<!-- /*公共头部带搜索*/ -->
			<div class="public_content">
				<div class="public_title_container">
					<p>新建分组</p>
					<a href="javascript:history.back(-1)">
						<svg t="1599462684269" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="8055" width="20" height="20"><path d="M501.2992 273.408l1.024-156.16L184.65792 379.904l314.29632 266.1376 0.95232-149.2992c313.86624 42.5984 178.29888 231.3216-0.5632 410.2144 619.5712-404.3776 251.01312-590.6432 1.95584-633.5488z" p-id="8056"></path></svg>
					</a>
				</div>

			</div>
			<!-- /*公共头部带搜索*/ end -->
			<!-- 公共表单部分 -->
			<div class="public_form_container">
				<div class="public_form_content">
					<div class="public_form_List">
						<div class="public_formTitle_container">
							<lable class="layui-form-label">分组名称：</lable>
						</div>
						<div class="public_formOther_container">
							<div class="layui-input-block">
								<input type="text" name="name" value="{$group->name}" required  lay-verify="required" placeholder="请输入分组名称" autocomplete="off" class="layui-input">
							</div>
						</div>
					</div>
				</div>

				<div class="public_form_content">
					<div class="public_form_List">
						<div class="public_formTitle_container">
							<lable class="layui-form-label">排序：</lable>
						</div>
						<div class="public_formOther_container">
							<div class="layui-input-block">
								<input type="text" name="sort" value="{$group->sort}" required  lay-verify="required" placeholder="排序" autocomplete="off" class="layui-input">
							</div>
						</div>
					</div>
				</div>

				<div class="layui-form-item">
					<div class="layui-input-block">
						<a class="layui-btn" lay-submit lay-filter="formDemo">提交并创建</a>
						<!--<button type="reset" class="layui-btn layui-btn-primary">重置</button>-->
					</div>
				</div>
			</div>
			<!-- 公共表单部分 end-->
		</div>
	</form>
	<script src="/cdn/jquery.js"></script>
	<script src="/layui/layui.js"></script>
	<script src="/js/ajax.js"></script>
	<script type="text/javascript">
		// 上传
		layui.use('upload', function(){
		  var upload = layui.upload;
		   
		  //执行实例
		  var uploadInst = upload.render({
		    accept: 'video'
			,field: 'file'
		    ,elem: '#uploadVideo' //绑定元素
		    ,url: 'upload_file.html' //上传接口
		    ,done: function(res){
				layer.msg(res.msg);
				if(res.status == 'success'){
					$('#video_path').val(res.data.filePath);
					$('#video_name').val(res.data.fileName);
					$('#video_name_show').html(res.data.fileName);
				}
		    }
		    ,error: function(){
		      //请求异常回调
		    }
		  });
		  var uploadInst2 = upload.render({
		    accept: 'file'
			,field: 'file'
		    ,elem: '#uploadFile' //绑定元素
		    ,url: 'upload_file.html' //上传接口
		    ,done: function(res){
		      layer.msg(res.msg);
			  if(res.status == 'success'){
				  $('#file_path').val(res.data.filePath);
				  $('#file_name').val(res.data.fileName);
				  $('#file_name_show').html(res.data.fileName);
			  }
		    }
		    ,error: function(){
		      //请求异常回调
		    }
		  });
		});
		// 日期
		layui.use('laydate', function(){
		  var laydate = layui.laydate;
		  
		  laydate.render({ 
		    elem: '#test1'
		    ,type: 'datetime'
		  });
		});
		// 弹窗
		layui.use('layer', function(){
		  var layer = layui.layer;
		}); 
		// 表单
		layui.use('form', function(){
		  var form = layui.form;
		  
		  //监听提交
		  form.on('submit(formDemo)', function(data){
		    //layer.msg(JSON.stringify(data.field));
		   // return false;
			var formData = $('#form1').serialize();	
			myAjaxPost(false, true, '', formData, function (resp) {
				if (resp.status == 'success') {
					layer.msg(resp.msg);
					setTimeout(function(){
						location.href = 'group_manage.html'; 
					},1000);
				}else{
					alert(resp.msg);
				}
			});
		  });
		  
		});
	</script>
	<script>
	layui.use(['element', 'layer', 'upload'], function () {
	  var layer = layui.layer;
	});
	$('.select_img').on('click',function  () {
	  var targetId=this.getAttribute('data-target');
	  layer.open({
		title:'图片库',
		type: 2,
		area: ['700px', '450px'],
		fixed: false, //不固定
		maxmin: false,
		content: '/imgLib/lib.html?type=vshop_img&target='+targetId
	  });
	})

	window.uploadImgCallback=function (tgt,url) {
	  console.log('选择图片结果',tgt,url);
	  if(tgt=='pic'){
		var inputEle=$('#pic');
		var prevEle=$('#pic_pic');
		inputEle.val(url);
		prevEle.attr('src',url);
		prevEle.show();
	  }else if(tgt=='link_pic'){
		var inputEle=$('#link_pic');
		var prevEle=$('#link_pic_pic');
		inputEle.val(url);
		prevEle.attr('src',url);
		prevEle.show();
	  }
	};
	</script>
</body>
</html>